package com.example.tse.rbhttpservice.service.home.model;

import com.example.tse.rbhttpservice.service.RudderResponse;

import java.util.ArrayList;
import java.util.List;

/**
 * 获取首页的囤货更省钱列表
 * @author wliu
 * edit tse
 */

public class HomeGetStockpileResponse extends RudderResponse{
    
    private List<HomeGetStockpile> getStockpile = new ArrayList<HomeGetStockpile>();
		
	
    /**
     * @return getStockpile
     */	
    public List<HomeGetStockpile> getGetStockpile() { 
	    return this.getStockpile;
    };
	
	/**
     * @return getStockpile
     */	
    public void setGetStockpile(List<HomeGetStockpile> getStockpile) { 
        this.getStockpile = getStockpile;
    };
    
	
        
    private static void filterFor(HomeGetStockpileGoods home) {
        if (home.getProductId() == null) {
            home.setProductId("");
        }
        if (home.getName() == null) {
            home.setName("");
        }
        if (home.getBn() == null) {
            home.setBn("");
        }
        if (home.getPrice() == null) {
            home.setPrice("");
        }
        if (home.getMktprice() == null) {
            home.setMktprice("");
        }
        if (home.getThumbnailPic() == null) {
            home.setThumbnailPic("");
        }
        if (home.getBeginTime() == null) {
            home.setBeginTime("");
        }
        if (home.getHasNotice() == null) {
            home.setHasNotice("");
        }
        if (home.getNum() == null) {
            home.setNum("");
        }
        if (home.getSpecialId() == null) {
            home.setSpecialId("");
        }
        if (home.getCurTime() == null) {
            home.setCurTime("");
        }
        if (home.getStoreNum() == null) {
            home.setStoreNum("");
        }
    }
        
    private static void filterFor(HomeGetStockpileAd home) {
        if (home.getUrl() == null) {
            home.setUrl("");
        }
        if (home.getLink() == null) {
            home.setLink("");
        }
        if (home.getLinkType() == null) {
            home.setLinkType("");
        }
    }
        
    private static void filterFor(HomeGetStockpile home) {
        if (home.getSpecialId() == null) {
            home.setSpecialId("");
        }
        if (home.getGoods() == null) {
            home.setGoods(new ArrayList<HomeGetStockpileGoods>());
        } else {
            for (HomeGetStockpileGoods item : home.getGoods()) {
                filterFor(item);
            }
        }
        if (home.getAd() == null) {
            home.setAd(new HomeGetStockpileAd());
        } else {
            filterFor(home.getAd());
        }
    }
        
    public static void filter(HomeGetStockpileResponse home) {
        if (home.getGetStockpile() == null) {
            home.setGetStockpile(new ArrayList<HomeGetStockpile>());
        } else {
            for (HomeGetStockpile item : home.getGetStockpile()) {
                filterFor(item);
            }
        }
    }
}
